# -*- coding: utf-8 -*-
from django.shortcuts import render
from django.http import HttpResponse
from django.http import JsonResponse
from django.views.decorators.csrf import csrf_exempt
import os
import json
import configparser
import requests
from django.http import HttpResponseRedirect
@csrf_exempt
def login(request):
    return render(request, "login.html")



@csrf_exempt
def check(request):
    # 获取用户提交的数据
    # print(request.POST)  # 取得所有 POST 过来的数据
    email = request.POST.get("email", None)
    pwd = request.POST.get("pwd", None)
    #print(email, pwd)
    # 判断是否登录成功
    if email == 'xuanyuan' and pwd == 'kg123456':
        # 创建或修改 session：
        response = HttpResponseRedirect('/')
        response.set_cookie('AGraph_AJQCDJOWN63628df','AGraph_AJQCDJOWN63628df',3600)
        return response 
    else:
        return render(request, "login.html")
